<html>
<head><meta charset="utf-8"><title>frontend library-ification · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html">frontend library-ification</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="175632694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175632694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175632694">(Sep 13 2019 at 15:04)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> mainly I think if we do libast/libparser/liblowering refactorings now, then it's way nicer to hack on diagnostics without having to recompile things only depending on AST but not parser</p>



<a name="175633064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633064">(Sep 13 2019 at 15:08)</a>:</h4>
<p>Seems fine for me to do!</p>



<a name="175633137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633137">(Sep 13 2019 at 15:08)</a>:</h4>
<p>It's just that it won't be <em>directly</em> beneficial for rust-analyzer, as I don't think it can use rustc AST</p>



<a name="175633165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633165">(Sep 13 2019 at 15:09)</a>:</h4>
<p>sure</p>



<a name="175633214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633214">(Sep 13 2019 at 15:09)</a>:</h4>
<p>My thoughts on extracting the parser is that there are two possible approaches:</p>
<ul>
<li>parser builds a specifc tree</li>
<li>parser is supplied with some callback interface (typed or untyped), and is agnostic of the tree</li>
</ul>



<a name="175633296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633296">(Sep 13 2019 at 15:10)</a>:</h4>
<p>Swift at the moment is transitioning to the CST based on the first idea</p>



<a name="175633310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633310">(Sep 13 2019 at 15:10)</a>:</h4>
<p>Basically, the parser builds two trees at once.</p>



<a name="175633341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633341">(Sep 13 2019 at 15:10)</a>:</h4>
<p>hmm would <code>syn</code> be considered a CST?</p>



<a name="175633366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633366">(Sep 13 2019 at 15:11)</a>:</h4>
<p>or is it more like a parse tree</p>



<a name="175633386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633386">(Sep 13 2019 at 15:11)</a>:</h4>
<p>Yeah, I should have said parse treee</p>



<a name="175633390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633390">(Sep 13 2019 at 15:11)</a>:</h4>
<p>syn seems like a CST</p>



<a name="175633401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633401">(Sep 13 2019 at 15:11)</a>:</h4>
<p>(with comments and whitespace)</p>



<a name="175633404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633404">(Sep 13 2019 at 15:11)</a>:</h4>
<p>syn tries to keep all the tokens AFAIK</p>



<a name="175633415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633415">(Sep 13 2019 at 15:11)</a>:</h4>
<p>(that it gets from <code>TokenStream</code>)</p>



<a name="175633428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633428">(Sep 13 2019 at 15:11)</a>:</h4>
<p>fair... seems like something in-between then</p>



<a name="175633482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633482">(Sep 13 2019 at 15:12)</a>:</h4>
<p>I think that's the definition of CST according to megamodel</p>



<a name="175633509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633509">(Sep 13 2019 at 15:12)</a>:</h4>
<p>and if you add ws and comments, you'll get a parse tree. Riht?</p>



<a name="175633527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633527">(Sep 13 2019 at 15:12)</a>:</h4>
<p>parse tree and CST seem synonymous according to wiki</p>



<a name="175633535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633535">(Sep 13 2019 at 15:12)</a>:</h4>
<blockquote>
<p>A parse tree or parsing tree[1] or derivation tree or concrete syntax tree is an ordered, rooted tree that represents the syntactic structure of a string according to some context-free grammar. The term parse tree itself is used primarily in computational linguistics; in theoretical syntax, the term syntax tree is more common.</p>
</blockquote>



<a name="175633578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633578">(Sep 13 2019 at 15:13)</a>:</h4>
<p>but not accodring to <a href="http://grammarware.github.io/parsing/" target="_blank" title="http://grammarware.github.io/parsing/">http://grammarware.github.io/parsing/</a></p>



<a name="175633675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633675">(Sep 13 2019 at 15:14)</a>:</h4>
<p>anyway, building both ast and parse tree seems nice</p>



<a name="175633723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633723">(Sep 13 2019 at 15:14)</a>:</h4>
<p><em>but</em> it makes the parser dependent on the AST, which will make it harder to use it in rust-analyzer, which totally doesn't want rustc's AST</p>



<a name="175633789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633789">(Sep 13 2019 at 15:15)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span>  can you tl;dr the reasons why rustc's AST is bad for RA?</p>



<a name="175633792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633792">(Sep 13 2019 at 15:15)</a>:</h4>
<p>An alternative is to make the parser just traverse a parse tree, without actually building it. Than rustc can produce AST out of it, and rust-analyzer will build a parsee tree</p>



<a name="175633900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633900">(Sep 13 2019 at 15:16)</a>:</h4>
<p>it has types, it has spans (more generally, identity), it doesn't have whiespace, it doesn't have comments,  it is mutable</p>



<a name="175633933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633933">(Sep 13 2019 at 15:17)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span>  sounds like you want another IR before <code>ast::</code> then</p>



<a name="175633956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633956">(Sep 13 2019 at 15:17)</a>:</h4>
<p>has types -- different nodes are represented by different Rust types</p>



<a name="175633962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633962">(Sep 13 2019 at 15:17)</a>:</h4>
<p>(we want to move away from mutability, at least I do :P)</p>



<a name="175633974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175633974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175633974">(Sep 13 2019 at 15:17)</a>:</h4>
<p>Yeah, exactly, I want parse tree</p>



<a name="175634072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634072">(Sep 13 2019 at 15:18)</a>:</h4>
<blockquote>
<ul>
<li>parser is supplied with some callback interface (typed or untyped), and is agnostic of the tree</li>
</ul>
</blockquote>
<p>This sounds like tagless-final; using a trait for "callback"</p>



<a name="175634082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634082">(Sep 13 2019 at 15:18)</a>:</h4>
<p>Another big thing for me is indentity: I want <code>a + b</code>  to always be just <code>a + b</code>, and not <code>a + b</code> in <code>main.rs:42:10</code></p>



<a name="175634113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634113">(Sep 13 2019 at 15:18)</a>:</h4>
<p>How to marry that with hygiene and macro expansion is an open question though...</p>



<a name="175634139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634139">(Sep 13 2019 at 15:18)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span>  i.e. you don't want spans</p>



<a name="175634180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634180">(Sep 13 2019 at 15:19)</a>:</h4>
<p>exactly</p>



<a name="175634217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634217">(Sep 13 2019 at 15:19)</a>:</h4>
<p>hmm</p>



<a name="175634269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634269">(Sep 13 2019 at 15:20)</a>:</h4>
<p>what if AST nodes were interned, with a single attached quantity</p>



<a name="175634277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634277">(Sep 13 2019 at 15:20)</a>:</h4>
<p>a "size"</p>



<a name="175634293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634293">(Sep 13 2019 at 15:20)</a>:</h4>
<p>which you could use to attach data to AST nodes in flat arrays</p>



<a name="175634300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634300">(Sep 13 2019 at 15:20)</a>:</h4>
<p>wait no this is the "relative node ID" thing</p>



<a name="175634304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634304">(Sep 13 2019 at 15:20)</a>:</h4>
<p>I just thought about it in a weird way</p>



<a name="175634308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634308">(Sep 13 2019 at 15:20)</a>:</h4>
<p>:D</p>



<a name="175634310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634310">(Sep 13 2019 at 15:20)</a>:</h4>
<p>(oops)</p>



<a name="175634315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634315">(Sep 13 2019 at 15:20)</a>:</h4>
<p>If we want a zero cost solution then another IR in-between <code>TokenStream</code> and <code>ast::</code> may be "expensive" for rustc in terms of compile-perf...</p>
<p>A tagless-final approach might be better</p>



<a name="175634344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634344">(Sep 13 2019 at 15:20)</a>:</h4>
<p>nah the current AST is not good by any stretch of the imagination</p>



<a name="175634363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634363">(Sep 13 2019 at 15:21)</a>:</h4>
<p>I'd rather replace it with something like this</p>



<a name="175634386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634386">(Sep 13 2019 at 15:21)</a>:</h4>
<p>how did I forget about the relative thing, now I need to figure out how to use it more...</p>



<a name="175634390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634390">(Sep 13 2019 at 15:21)</a>:</h4>
<blockquote>
<p>nah the current AST is not good by any stretch of the imagination</p>
</blockquote>
<p>Sure, but an added <del>pass</del> transform might make not-good worse?</p>



<a name="175634411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634411">(Sep 13 2019 at 15:21)</a>:</h4>
<p>you'd not have a pass</p>



<a name="175634464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634464">(Sep 13 2019 at 15:22)</a>:</h4>
<p>you'd use the superior representation directly :P</p>



<a name="175634511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634511">(Sep 13 2019 at 15:22)</a>:</h4>
<p>Yeah, I think we just don't need AST ideally. We can run nameres/macro expansion on the parse tree, and then lower the bodies into a proper simple IR (HIR or direclty MIR)</p>



<a name="175634555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634555">(Sep 13 2019 at 15:23)</a>:</h4>
<p>(basically anything that is tree-shaped can have data attached to it in a similar tree shape <em>or</em> in a flat manner with just a single "total number of subnodes" number per node)</p>



<a name="175634563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634563">(Sep 13 2019 at 15:23)</a>:</h4>
<p>I want to implement this <em>so badly</em> right now</p>



<a name="175634713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634713">(Sep 13 2019 at 15:24)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> yeah, that's roughly the plan for rust-analyzer. We currently use in-file offsets and not sizes, but that's not a super big difference</p>



<a name="175634732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634732">(Sep 13 2019 at 15:24)</a>:</h4>
<blockquote>
<p>We can run nameres/macro expansion on the parse tree, and then lower the bodies into a proper simple IR (HIR or direclty MIR)</p>
</blockquote>
<p>Sounds like it would complicate spec efforts tho? nameres on a more "untyped" structure sounds harder to specify... Also, idk how you get directly to MIR lol...</p>



<a name="175634788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175634788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175634788">(Sep 13 2019 at 15:25)</a>:</h4>
<p>You can have typed views over untyped datastructure</p>



<a name="175635088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635088">(Sep 13 2019 at 15:28)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> sounds like "typing it" on-demand?</p>



<a name="175635345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635345">(Sep 13 2019 at 15:30)</a>:</h4>
<p>I mean "do what Swift libsyntax does"</p>



<a name="175635398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635398">(Sep 13 2019 at 15:31)</a>:</h4>
<p>A nice benefit here is that the green layer of Swift's syntax is so simple, that I feel it could be safely put into a shared interface</p>



<a name="175635416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635416">(Sep 13 2019 at 15:31)</a>:</h4>
<p>Hm, <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="175635528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635528">(Sep 13 2019 at 15:32)</a>:</h4>
<blockquote>
<p>I mean "do what Swift libsyntax does"</p>
</blockquote>
<p>Guess I have to look more at swift then =)</p>



<a name="175635720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635720">(Sep 13 2019 at 15:34)</a>:</h4>
<p>Yeah, I think if the parser builds a dumb green tree, that would be a rather simple an uncontroversial way forwad.</p>
<p>That is, at the first stage, parer produces a green tree, and then we build a currrent AST over it (this increases alloc pressure somewhat, but I believe we can temporary stomach it just fine)</p>
<p>At the next stage, we slowly replace processing of the AST with processing of the green tree (my understanding is that immutable green tree is basically what <span class="user-mention" data-user-id="119009">@eddyb</span> wants)</p>
<p>At the next stage, if we find a need for this, we implement a red layer for convenience API on top</p>



<a name="175635793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635793">(Sep 13 2019 at 15:35)</a>:</h4>
<blockquote>
<p>We currently use in-file offsets and not sizes, but that's not a super big difference</p>
</blockquote>
<p>I mean "node count" not "source length"</p>



<a name="175635797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635797">(Sep 13 2019 at 15:35)</a>:</h4>
<p><a href="https://github.com/apple/swift/tree/master/lib/Syntax" target="_blank" title="https://github.com/apple/swift/tree/master/lib/Syntax">https://github.com/apple/swift/tree/master/lib/Syntax</a> &lt;- I consider this a required reading for discussing IDE syntax trees</p>



<a name="175635804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635804">(Sep 13 2019 at 15:35)</a>:</h4>
<p>this allows attaching e.g. spans orthogonally</p>



<a name="175635850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635850">(Sep 13 2019 at 15:36)</a>:</h4>
<p>and interning the AST!</p>



<a name="175635874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635874">(Sep 13 2019 at 15:36)</a>:</h4>
<p>I wonder if you could have layers of interning :P</p>



<a name="175635878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635878">(Sep 13 2019 at 15:36)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> source <em>lenght</em> (as opposed to offsets) allows interning as well. I actually do that in rowan</p>



<a name="175635929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635929">(Sep 13 2019 at 15:37)</a>:</h4>
<p>so <code>a + b</code> twice would be interned at both levels, but <code>a + b</code> vs <code>a+b</code> would only share one interning level</p>



<a name="175635933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635933">(Sep 13 2019 at 15:37)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rowan/blob/a00ccb60ea99eccbc7f24d31ee83e925e0d8258d/src/green.rs#L151-L156" target="_blank" title="https://github.com/rust-analyzer/rowan/blob/a00ccb60ea99eccbc7f24d31ee83e925e0d8258d/src/green.rs#L151-L156">https://github.com/rust-analyzer/rowan/blob/a00ccb60ea99eccbc7f24d31ee83e925e0d8258d/src/green.rs#L151-L156</a></p>



<a name="175635943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635943">(Sep 13 2019 at 15:37)</a>:</h4>
<p>^ interning</p>



<a name="175635983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175635983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175635983">(Sep 13 2019 at 15:37)</a>:</h4>
<p>yeah I know but code being written exactly the same twice is not necessarily as likely</p>



<a name="175636197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/175636197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#175636197">(Sep 13 2019 at 15:40)</a>:</h4>
<p>That's true, but I am not sure we need more layers between "parse tree" and "name resolves AST"</p>



<a name="183374188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183374188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183374188">(Dec 13 2019 at 16:16)</a>:</h4>
<p><span class="user-mention" data-user-id="116013">@qmx</span> in terms of reading material, I'd say that <a href="https://github.com/apple/swift/tree/master/lib/Syntax" target="_blank" title="https://github.com/apple/swift/tree/master/lib/Syntax">https://github.com/apple/swift/tree/master/lib/Syntax</a> is still the best concentrated source of info. The libsyntax2 RFCs is also still mostly relevant</p>



<a name="183374300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183374300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183374300">(Dec 13 2019 at 16:17)</a>:</h4>
<p>@matklad <span class="user-mention" data-user-id="126931">@centril</span> I landed here from the design meeting log... if either of you is interested in documenting the parser for the rustc-guide (after refactorings) that would be awesome!</p>



<a name="183374367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183374367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183374367">(Dec 13 2019 at 16:18)</a>:</h4>
<p>There are no super good docs about how rust-analyzer syntax tree and parser works right now. I think it will be useful for me to write such a document, as I think we've almost reached the fixed point of the design</p>



<a name="183374493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183374493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183374493">(Dec 13 2019 at 16:19)</a>:</h4>
<p><span class="user-mention" data-user-id="119031">@Esteban Küber</span> you were interested in changing the number of people with shared knowledge of rustc + ra parsers/syntax trees. </p>
<p>I think I can ramp up anybody pretty quickly regarging ra implementation. The only condition for success is that the person needs to implement some small feature for rust-analyzer, just to get the feeling of the real API</p>



<a name="183374599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183374599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183374599">(Dec 13 2019 at 16:20)</a>:</h4>
<p><span class="user-mention" data-user-id="198054">@mark-i-m</span> documenting librustc_parse would probably be something for me then since I've sorta become the expert on that crate now</p>



<a name="183374622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183374622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183374622">(Dec 13 2019 at 16:21)</a>:</h4>
<p>I'm not sure what granularity you're seeking</p>



<a name="183374639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183374639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183374639">(Dec 13 2019 at 16:21)</a>:</h4>
<p>The source code is getting fairly well documented</p>



<a name="183374672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183374672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183374672">(Dec 13 2019 at 16:21)</a>:</h4>
<p>For <em>existing</em> reading material about rust-analyzer specifically, this API walkthrough tests is a good starting point: <a href="https://github.com/rust-analyzer/rust-analyzer/blob/ebc95af2b5b91239fc1d8a5fc8344ded6f6ef3e4/crates/ra_syntax/src/lib.rs#L193" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/blob/ebc95af2b5b91239fc1d8a5fc8344ded6f6ef3e4/crates/ra_syntax/src/lib.rs#L193">https://github.com/rust-analyzer/rust-analyzer/blob/ebc95af2b5b91239fc1d8a5fc8344ded6f6ef3e4/crates/ra_syntax/src/lib.rs#L193</a></p>



<a name="183374838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183374838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183374838">(Dec 13 2019 at 16:23)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> also, now that we've split librustc_parse into its own crate, things should probably get a bit easier</p>



<a name="183374955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183374955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183374955">(Dec 13 2019 at 16:24)</a>:</h4>
<blockquote>
<p>I think it will be useful for me to write such a document,</p>
</blockquote>
<p>Hm, <span class="user-mention" data-user-id="119031">@Esteban Küber</span> , what about this deal: <strong>you</strong> write this document, but I am obliged to answer all your questions, give required screen-sharing sessions, etc? :)</p>



<a name="183375026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183375026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183375026">(Dec 13 2019 at 16:25)</a>:</h4>
<p>maybe I should join in on that</p>



<a name="183375053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183375053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183375053">(Dec 13 2019 at 16:25)</a>:</h4>
<p>(the goal here is not to save my work, but to forcefully dissipate knowledge)</p>



<a name="183375065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183375065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> qmx <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183375065">(Dec 13 2019 at 16:25)</a>:</h4>
<p>I want in too</p>



<a name="183375076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183375076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183375076">(Dec 13 2019 at 16:25)</a>:</h4>
<p>That would be interesting, I just don't know what my availability will be ^_^</p>



<a name="183375153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183375153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183375153">(Dec 13 2019 at 16:26)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> right; and it would be good if e.g. <span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> also were in on it</p>



<a name="183375180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183375180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183375180">(Dec 13 2019 at 16:26)</a>:</h4>
<p>maybe not the writing, but also understanding RA</p>



<a name="183375213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183375213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183375213">(Dec 13 2019 at 16:26)</a>:</h4>
<p>Once we have the doc, anyone should be able to understand how syntax works</p>



<a name="183375246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183375246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183375246">(Dec 13 2019 at 16:27)</a>:</h4>
<p>but I may have questions also, which is why I want in ^^</p>



<a name="183375614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183375614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183375614">(Dec 13 2019 at 16:31)</a>:</h4>
<p>I think it makes sense if there's a single <em>core</em> person, who is in charge of understanding everything and putting it down to paper.  This can be me (as I've already did the first half), or somebody else. I estimate the amount of work here as 1 day.</p>
<p><span class="user-mention" data-user-id="119031">@Esteban Küber</span> , <span class="user-mention" data-user-id="116013">@qmx</span> <span class="user-mention" data-user-id="126931">@centril</span> who wants to make a commitment here? :)</p>



<a name="183383757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/183383757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#183383757">(Dec 13 2019 at 18:07)</a>:</h4>
<p>I can try, but again, I won't be available until the upcoming year</p>



<a name="185224466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/185224466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#185224466">(Jan 09 2020 at 15:51)</a>:</h4>
<p>I am starting with an old-school markdown document: <a href="https://hackmd.io/XoQrzR8GRLa64jpjylQ7Bw" target="_blank" title="https://hackmd.io/XoQrzR8GRLa64jpjylQ7Bw">https://hackmd.io/XoQrzR8GRLa64jpjylQ7Bw</a></p>



<a name="185237750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/185237750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#185237750">(Jan 09 2020 at 17:57)</a>:</h4>
<p>I've run out of steam for today (and will be running to my German class), so, if you have time, it's a good time to comment on what's not clear so far (and point/correct uncountable number of typos :) )</p>



<a name="185241653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/185241653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> qmx <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#185241653">(Jan 09 2020 at 18:38)</a>:</h4>
<p>cool, I'll do a review pass</p>



<a name="185241673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/185241673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> qmx <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#185241673">(Jan 09 2020 at 18:38)</a>:</h4>
<p>thanks for the write-up, it's great even in draft form</p>



<a name="185312514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/185312514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#185312514">(Jan 10 2020 at 14:10)</a>:</h4>
<p>Finished the second part about parsing.</p>



<a name="185312575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/185312575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#185312575">(Jan 10 2020 at 14:11)</a>:</h4>
<p>I'll draft a concrete proposal for librari-ification, which I hope to dedicate a t-compiler design meeting to: <a href="https://hackmd.io/ifjST_Y4R-SQ0AWiEcU6FQ" target="_blank" title="https://hackmd.io/ifjST_Y4R-SQ0AWiEcU6FQ">https://hackmd.io/ifjST_Y4R-SQ0AWiEcU6FQ</a></p>



<a name="185321639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/185321639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> qmx <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#185321639">(Jan 10 2020 at 15:48)</a>:</h4>
<p>I only fixed a typo on the first review pass</p>



<a name="185321649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/185321649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> qmx <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#185321649">(Jan 10 2020 at 15:48)</a>:</h4>
<p>lemme read the second part</p>



<a name="185324733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/185324733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> qmx <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#185324733">(Jan 10 2020 at 16:19)</a>:</h4>
<p>it feels to me that the Parser section was a little bit more abstract than the rest , but it still reads good</p>



<a name="185325335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/185325335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> qmx <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#185325335">(Jan 10 2020 at 16:25)</a>:</h4>
<p>I'll try to read the code around Sink and Source to see if things get a little bit clearer to me (might be my lack of exposure to the rust-analyzer code)</p>



<a name="185340096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/frontend%20library-ification/near/185340096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/frontend.20library-ification.html#185340096">(Jan 10 2020 at 19:01)</a>:</h4>
<p>Finished proposal and submitted a meeting proposal</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>